# -*- coding: utf-8 -*-
# @version : 1.0
# @File    : constant.py
# @Date    : 2024/9/27 23:31
# @Author  : GlenZhao
# @Desc    :

from enum import Enum, unique
from typing import Any


class Base(Enum):
    def __str__(self):
        return self.value


@unique
class PlatformEnum(Base):
    SELF = 'self'
    WEIXIN = 'weixin'
    META = 'meta'


@unique
class MultiLangEnum(Base):
    ZH_CN = 'zh-CN'
    EN_US = 'en-US'


@unique
class MultiLangTypeEnum(Base):
    COMPANY = 'company'
    COMPANY_EXTRA = 'company_extra'
    PRODUCT_CATEGORY = "product_category"
    PRODUCT_ITEM = 'product_item'
    SITE = "site"


@unique
class ErrorsEnum(Enum):
    def __init__(self, msg: str, code: int, desc: Any | None = None):
        self.msg = msg
        self.code = code
        self.desc = desc

    NO_PERMISSION = ('没有操作权限', 10000001, '')
    USER_NOT_EXIST = ('用户不存在', 10000100, '')
    MOBILE_EXIST = ('手机号已被注册', 10000101, {})
    INVALID_CAPTCHA = ('验证码不正确', 10000102, '')
    NOT_FOUND = ('记录不存在', 10000103, '')
    PARAMS_ERROR = ('参数错误', 10000104, '')

    # License
    LICENSE_MAC_ADDRESS_USED = ('MAC地址已绑定其它激活码', 10000200, '')
    LICENSE_USED = ('激活码已被使用', 10000201, '')
    LICENSE_OUT_TASK_NUM_LIMIT = ('超出任务数量', 10000202, '')
    LICENSE_EXPIRED = ('激活码已过期', 10000203, '')
    # JOB
    

    def to_dict(self):
        return {
            'msg': self.msg,
            'code': self.code,
            'desc': self.desc
        }

@unique
class JobStatusEnum(Base):
    WAITING = 'waiting'
    RUNNING = 'running'
    SUCCESS = 'success'
    FAILED = 'failed'

@unique
class TaskActionEnum(Base):
    SCREENSHOT = "screenshot"